package com.gdkj.util;

import com.gdkj.entity.UsersLive;
import com.gdkj.rabbitmq.BaseMessage;
import com.gdkj.rabbitmq.game.*;
import com.gdkj.rabbitmq.home.*;
import com.gdkj.rabbitmq.user.UserIp;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.UUID;

public class DelayMessageBuilder {

    public static void setCommonParams(BaseMessage baseMessage) {
        baseMessage.setUuid(UUID.randomUUID().toString().replace("-", ""));
        baseMessage.setTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
    }

    public static DelayDestroyGroup getDelayDestroyGroup(String groupId, Long liveUid) {
        DelayDestroyGroup delayDestroyGroup = new DelayDestroyGroup();
        delayDestroyGroup.setGroupId(groupId);
        delayDestroyGroup.setAction(Constants.DELAY_DESTROY_GROUP);
        delayDestroyGroup.setLiveUid(liveUid);
        setCommonParams(delayDestroyGroup);
        return delayDestroyGroup;
    }

    public static DelayStopRoom getDelayStopRoom(Long uid) {
        DelayStopRoom delayDestroyGroup = new DelayStopRoom();
        delayDestroyGroup.setUid(uid);
        delayDestroyGroup.setAction(Constants.DELAY_STOP_ROOM);
        setCommonParams(delayDestroyGroup);
        return delayDestroyGroup;
    }

    public static DelayLeaveRoom getDelayLeaveRoom(Long uid, Long liveUid) {
        DelayLeaveRoom delayLeaveRoom = new DelayLeaveRoom();
        delayLeaveRoom.setUid(uid);
        delayLeaveRoom.setLiveUid(liveUid);
        delayLeaveRoom.setAction(Constants.DELAY_LEAVE_ROOM);
        setCommonParams(delayLeaveRoom);
        return delayLeaveRoom;
    }

    public static DelayRecommendFullRoom getDelayRecommendFullRoom(Long id, Long uid) {
        DelayRecommendFullRoom delayRecommendFullRoom = new DelayRecommendFullRoom();
        delayRecommendFullRoom.setId(id);
        delayRecommendFullRoom.setUid(uid);
        setCommonParams(delayRecommendFullRoom);
        return delayRecommendFullRoom;
    }

    public static DelayMatchCreateRoom getDelayMatchCreateRoom(Long id, Long uid) {
        DelayMatchCreateRoom delayMatchCreateRoom = new DelayMatchCreateRoom();
        delayMatchCreateRoom.setId(id);
        delayMatchCreateRoom.setUid(uid);
        setCommonParams(delayMatchCreateRoom);
        return delayMatchCreateRoom;
    }

    public static StopRoomClearCache getStopRoomClearCache(Long uid, String stream) {
        StopRoomClearCache stopRoomClearCache = new StopRoomClearCache();
        stopRoomClearCache.setUid(uid);
        stopRoomClearCache.setStream(stream);
        setCommonParams(stopRoomClearCache);
        return stopRoomClearCache;
    }

    public static StopRoomCreateRecord getStopRoomCreateRecord(Long uid) {
        StopRoomCreateRecord stopRoomCreateRecord = new StopRoomCreateRecord();
        stopRoomCreateRecord.setUid(uid);
        setCommonParams(stopRoomCreateRecord);
        return stopRoomCreateRecord;
    }

    public static DelayNetRecovery getDelayNetRecovery(Long liveUid, Long uid) {
        DelayNetRecovery delayNetRecovery = new DelayNetRecovery();
        delayNetRecovery.setLiveUid(liveUid);
        delayNetRecovery.setUid(uid);
        setCommonParams(delayNetRecovery);
        return delayNetRecovery;
    }

    public static TestObject getTestObject(Long uid) {
        TestObject testObject = new TestObject();
        testObject.setUid(uid);
        setCommonParams(testObject);
        return testObject;
    }

    public static UserIp getUserIp(Long uid, String ip, String deviceId) {
        UserIp userIp = new UserIp();
        userIp.setUid(uid);
        userIp.setIp(ip);
        userIp.setDeviceId(deviceId);
        setCommonParams(userIp);
        return userIp;
    }

    public static DelayMikeEnoughGameSoonStart getDelayMikeEnoughGameSoonStart(UsersLive usersLive, Integer uid) {
        DelayMikeEnoughGameSoonStart delayMikeEnoughGameSoonStart = new DelayMikeEnoughGameSoonStart();
        delayMikeEnoughGameSoonStart.setUsersLive(usersLive);
        delayMikeEnoughGameSoonStart.setUid(uid);
        setCommonParams(delayMikeEnoughGameSoonStart);
        return delayMikeEnoughGameSoonStart;
    }

    public static DelayUserKick getDelayUserKick(UsersLive usersLive, Integer uid) {
        DelayUserKick delayUserKick = new DelayUserKick();
        delayUserKick.setUsersLive(usersLive);
        delayUserKick.setUid(uid);
        setCommonParams(delayUserKick);
        return delayUserKick;
    }

    public static DelayGameReadyOver getDelayGameReadyOver(UsersLive usersLive) {
        DelayGameReadyOver delayGameReadyOver = new DelayGameReadyOver();
        delayGameReadyOver.setUsersLive(usersLive);
        setCommonParams(delayGameReadyOver);
        return delayGameReadyOver;
    }

    public static DelayNumberBombAnswer getDelayNumberBombAnswer(UsersLive usersLive, Integer uid) {
        DelayNumberBombAnswer delayNumberBombAnswer = new DelayNumberBombAnswer();
        delayNumberBombAnswer.setUsersLive(usersLive);
        delayNumberBombAnswer.setUid(uid);
        setCommonParams(delayNumberBombAnswer);
        return delayNumberBombAnswer;
    }


    public static DelayGameOverAnswer getDelayGameOverAnswer(UsersLive usersLive) {
        DelayGameOverAnswer delayGameOverAnswer = new DelayGameOverAnswer();
        delayGameOverAnswer.setUsersLive(usersLive);
        setCommonParams(delayGameOverAnswer);
        return delayGameOverAnswer;
    }

    public static DelayGameLoadingTimeout getDelayGameLoadingTimeout(UsersLive usersLive) {
        DelayGameLoadingTimeout delayGameLoadingTimeout = new DelayGameLoadingTimeout();
        delayGameLoadingTimeout.setUsersLive(usersLive);
        setCommonParams(delayGameLoadingTimeout);
        return delayGameLoadingTimeout;
    }

//    public static UserIp getUserIp(Long uid, String ip) {
//        UserIp userIp = new UserIp();
//        userIp.setUid(uid);
//        userIp.setIp(ip);
//        setCommonParams(userIp);
//        return userIp;
//    }
}
